package ventana;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagLayout;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class Fondo extends JPanel {
	private JPanel contentPane=null;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ImageIcon  imagen;


	/**
	 * Create the panel.
	 */
	public Fondo(String nombre) {
		super();
		initialize();
		 imagen = new ImageIcon(getClass().getResource(nombre));
		 setSize(imagen.getIconWidth(),imagen.getIconHeight());
	}
	 

	private void initialize() {
		 this.setSize(300,200);
		  
	}
	private  Fondo getJcontentPane(){
		if(contentPane == null){
			contentPane=new Fondo("pub.jpg");
			contentPane.setLayout(new BorderLayout());
		}
		return (Fondo) contentPane;
	}
 protected void paintComponent(Graphics g){
	 Dimension d= getSize();
	 ImageIcon imagen= new ImageIcon(getClass().getResource("/ventana/pub.jpg"));
	 g.drawImage(imagen.getImage(), 0, 0, d.width, d.height, null);
	 this.setOpaque(false);
	 super.paintComponents(g);
 }
}
